import request from '@/axios'
import { SysRoleDetailVo, SysRoleEditQo, SysRoleListVo, SysRoleSearchQo } from './types'
import { BaseDeleteQo } from '@/base/api/BaseQo'
import { KeyLabelValueVo } from '@/base/api/KeyLabelValueVo'

export const sysRolePageApi = (data: SysRoleSearchQo): Promise<IResponse<Array<SysRoleListVo>>> => {
  return request.post({ url: '/sysRole/page.adw', data })
}

export const sysRoleDetailApi = (id: number): Promise<IResponse<SysRoleDetailVo>> => {
  const data = { id }
  return request.post({
    url: '/sysRole/detail.adw',
    data
  })
}

export const sysRoleAddApi = (data: SysRoleEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysRole/add.adw', data })
}

export const sysRoleUpdateApi = (data: SysRoleEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysRole/update.adw', data })
}

export const sysRoleDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysRole/delete.adw', data })
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]
export const selectSysRoleNameListApi = (
  data: SysRoleSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysRole/selectNameList.adw', data })
}
export const selectSysRoleCodeListApi = (
  data: SysRoleSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysRole/selectCodeList.adw', data })
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
